package com.itheima.health.job;

import com.itheima.health.dao.TimeDeleteDao;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class TimeDelete {
    @Autowired
    TimeDeleteDao timeDeleteDao;

    //定时删除预约历史数据
    public void deleteInfo(){
        //计算的出当前月
        Calendar calendar=Calendar.getInstance();
        //根据当前时间计算，将Calendar向前推1个月(2019-10)
        calendar.add(Calendar.MONTH,-1);
        //得出时间
        String format = new SimpleDateFormat("YYYY-MM-dd").format(calendar.getTime());

        timeDeleteDao.delete(format);

    }
}
